function Animal() {
  this.name = 'dog'
}

class Animal2 {
  constructor() {
    this.name = ''
  }
}


function Parent() {
  this.name = 'parent'
}

Parent.prototype.say = function () {
  console.log('hello')
};

function Child() {
  this.type = "Child"
}


// 借助原型链实现继承

Child.prototype = new Parent();

c1 = new Child();


// 组合方式实现继承
//缺点：
function Parent1() {
  this.name = 'parent';
  this.play = [1,2,3];
}

Parent1.prototype.say = function () {
  console.log('hello')
};

function Child1() {
  Parent1.call(this);
  this.type = 'child3';
}

Child1.prototype = new Parent1();

var s1 = new Child1();
var s2 = new Child1();
s1.play.push(4);
console.log(s1.play, s2.play); //[1,2,3,4], [1,2,3]
